home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Archives / GNU / GNUPLOTsrc.lha / term / regis.trm < prev    next >
Encoding:
Text File  |  1996-01-22  |  5.7 KB  |  248 lines

  1. /*
  2.  * $Id: regis.trm,v 1.10 1995/12/20 21:48:11 drd Exp $
  3.  *
  4.  */
  5.  
  6. /* GNUPLOT - regis.trm */
  7. /*
  8.  * Copyright (C) 1990 - 1993   
  9.  *
  10.  * Permission to use, copy, and distribute this software and its
  11.  * documentation for any purpose with or without fee is hereby granted, 
  12.  * provided that the above copyright notice appear in all copies and 
  13.  * that both that copyright notice and this permission notice appear 
  14.  * in supporting documentation.
  15.  *
  16.  * Permission to modify the software is granted, but not the right to
  17.  * distribute the modified code.  Modifications are to be distributed 
  18.  * as patches to released version.
  19.  *  
  20.  * This software  is provided "as is" without express or implied warranty.
  21.  * 
  22.  * This file is included by ../term.c.
  23.  *
  24.  * This terminal driver supports:
  25.  *  REGIS devices
  26.  *
  27.  * AUTHORS
  28.  *  Colin Kelley, Thomas Williams
  29.  * 
  30.  * send your comments or suggestions to (info-gnuplot@dartmouth.edu).
  31.  * 
  32.  */
  33.  
  34. #ifndef GOT_DRIVER_H
  35. #include "driver.h"
  36. #endif
  37.  
  38. #ifdef TERM_REGISTER
  39. register_term(regis)
  40. #endif
  41.  
  42.  
  43. #ifdef TERM_PROTO
  44. TERM_PUBLIC void REGISinit __P((void));
  45. TERM_PUBLIC void REGISgraphics __P((void));
  46. TERM_PUBLIC void REGISinit __P((void));
  47. TERM_PUBLIC void REGISgraphics __P((void));
  48. TERM_PUBLIC void REGIStext __P((void));
  49. TERM_PUBLIC void REGISlinetype __P((int linetype));
  50. TERM_PUBLIC void REGISmove __P((unsigned int x, unsigned int y));
  51. TERM_PUBLIC void REGISvector __P((unsigned int x, unsigned int y));
  52. TERM_PUBLIC void REGISput_text __P((unsigned int x, unsigned int y, char *str));
  53. TERM_PUBLIC int REGIStext_angle __P((int ang));
  54. TERM_PUBLIC void REGISreset __P((void));
  55. TERM_PUBLIC void REGISoptions __P((void));
  56.  
  57. #define REGISXMAX 800             
  58. #define REGISYMAX 440
  59.  
  60. #define REGISXLAST (REGISXMAX - 1)
  61. #define REGISYLAST (REGISYMAX - 1)
  62.  
  63. #define REGISVCHAR        20      
  64. #define REGISHCHAR        9
  65. #define REGISVTIC        8
  66. #define REGISHTIC        6
  67.  
  68. #define TRUE 1
  69. #define FALSE 0
  70. #endif
  71.  
  72.  
  73.  
  74. #ifndef TERM_PROTO_ONLY
  75. #ifdef TERM_BODY
  76.  
  77. static int REGIS16color=FALSE;
  78.  
  79. static int REGISang = 0;
  80.  
  81. TERM_PUBLIC void REGISinit()
  82. {
  83.     fprintf(outfile,"\033[r\033[24;1H");
  84. /*                   1     2
  85.     1. reset scrolling region
  86.     2. locate cursor on bottom line
  87. */
  88. }
  89.  
  90.  
  91. /* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */
  92. TERM_PUBLIC void REGISgraphics()
  93. {
  94.     fprintf(outfile,"\033[2J\033P1pS(C0)S(E)T(A0)\n");
  95. /*                   1      2      3    4   5
  96.         1. clear screen
  97.         2. enter ReGIS graphics
  98.         3. turn off graphics diamond cursor
  99.         4. clear graphics screen
  100.         5. character set option.
  101. */
  102.         (void) REGIStext_angle(0); /* select text size and angle */
  103. }
  104.  
  105.  
  106. TERM_PUBLIC void REGIStext()
  107. {
  108.     fprintf(outfile,"\033\\\033[24;1H");
  109. /*                       1    2
  110.     1. Leave ReGIS graphics mode
  111.      2. locate cursor on last line of screen
  112. */
  113. }
  114.  
  115.  
  116. TERM_PUBLIC void REGISlinetype(linetype)
  117. int     linetype;
  118. {
  119.       /* This will change color in order G,R,B,G-dot,R-dot,B-dot */
  120.  
  121. static int in_16_map[15+2] = {7,7,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15};
  122. static int lt_16_map[15+2] = {1,4,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1};
  123. static int in_map[9 + 2] = {2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1};
  124. static int lt_map[9 + 2] = {1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6};
  125.    
  126.        if(!REGIS16color)
  127.        {    if (linetype >= 9)
  128.                linetype %= 9;
  129.            fprintf(outfile, "W(I%d)\n", in_map[linetype + 2]);
  130.            fprintf(outfile, "W(P%d)\n", lt_map[linetype + 2]);
  131.        }
  132.        else
  133.        {    if(linetype >=15)
  134.                linetype %= 15;
  135.            fprintf(outfile, "W(I%d)\n", in_16_map[linetype + 2]);
  136.            fprintf(outfile, "W(P%d)\n", lt_16_map[linetype + 2]);
  137.        }
  138. }
  139.  
  140.  
  141.  
  142. /*
  143. ** The \n was added in the functions below (and above) in order to not cause
  144. ** a buffer overflow in devices that can't deal with long line lengths.
  145. ** The DEC vt-340 doesn't need this, but Reflection 4, a vt-340 emulator
  146. ** for PC's under MS-DOS and Microsoft Windows does need it.
  147. ** Also needed for DECterm, a vt-340 emulator for use with Motif 1.0
  148. ** on Open/VMS.
  149. ** NGB 9/13/93
  150. */
  151.  
  152. TERM_PUBLIC void REGISmove(x,y)
  153. unsigned int x,y;
  154. {
  155.     fprintf(outfile,"P[%d,%d]\n",x,REGISYLAST-y);
  156. }
  157.  
  158.  
  159. TERM_PUBLIC void REGISvector(x,y)
  160. unsigned int x,y;
  161. {
  162.     fprintf(outfile,"v[]v[%d,%d]\n",x,REGISYLAST - y);
  163. /* the initial v[] is needed to get the first pixel plotted */
  164. }
  165.  
  166.  
  167. /* put_text and text_angle by rjl */
  168. TERM_PUBLIC void REGISput_text(x,y,str)
  169. unsigned int x, y;
  170. char *str;
  171. {
  172.     if (REGISang==1)
  173.         REGISmove(x-REGISVCHAR/2-1,y);
  174.     else
  175.         REGISmove(x,y+REGISVCHAR/2-1);
  176.     (void) putc('T',outfile); (void) putc('\'',outfile);
  177.     while (*str) {
  178.         (void) putc(*str,outfile);
  179.         if (*str == '\'')
  180.             (void) putc('\'',outfile);    /* send out another one */
  181.         str++;
  182.     }
  183.     (void) putc('\'',outfile);
  184.     (void) putc('\n',outfile);
  185. }
  186.  
  187.  
  188. TERM_PUBLIC int REGIStext_angle(ang)
  189. int ang;
  190. {
  191.     REGISang = ang;
  192.     if (ang == 1)
  193.         fputs("T(D90,S1)\n",outfile);
  194.     else
  195.         fputs("T(D0,S1)\n",outfile);
  196.     return TRUE;
  197. }
  198.  
  199.  
  200. TERM_PUBLIC void REGISreset()
  201. {
  202.     fprintf(outfile,"\033[2J\033[24;1H");
  203. }
  204.  
  205. TERM_PUBLIC void REGISoptions()
  206. {    int i=0;
  207.        struct value a;
  208.  
  209.        if(!END_OF_COMMAND)
  210.        {    i=(int)real(const_express(&a));
  211.        }
  212.        REGIS16color= (i==16);
  213.        sprintf(term_options,"%s",REGIS16color?"16":"4");
  214. }
  215.  
  216. #endif
  217.  
  218.  
  219. #ifdef TERM_TABLE
  220.  
  221. TERM_TABLE_START(regis_driver)
  222.  
  223.       "regis", "REGIS graphics language",
  224.        REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, 
  225.        REGISVTIC, REGISHTIC, REGISoptions, REGISinit, REGISreset, 
  226.        REGIStext, null_scale, REGISgraphics, REGISmove, REGISvector,
  227.        REGISlinetype, REGISput_text, REGIStext_angle, 
  228.        null_justify_text, line_and_point, do_arrow, set_font_null}
  229.  
  230. #undef LAST_TERM
  231. #define LAST_TERM regis_driver
  232. #endif
  233. #endif /* TERM_PROTO_ONLY */
  234.  
  235.  
  236. #ifdef TERM_HELP
  237. START_HELP(regis)
  238. "1 regis",
  239. "?set terminal regis",
  240. "?regis",
  241. " The `regis` terminal device has the option of using 4 or 16 colors.  The",
  242. " default is 4.  For example:",
  243. "",
  244. "        set term regis 16"
  245. END_HELP(regis)
  246. #endif
  247.  
  248.